<?php

// +----------------------------------------------------------------------
// | Think.Admin
// +----------------------------------------------------------------------
// | 版权所有 2014~2017 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
// +----------------------------------------------------------------------
// | 官方网站: http://think.ctolog.com
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | github开源项目：https://github.com/zoujingli/Think.Admin
// +----------------------------------------------------------------------

namespace app\store\service;

use service\DataService;
use service\ToolsService;
use think\Db;

/**
 * 商城订单服务
 * Class OrderService
 * @package app\store
 */
class MessageService
{

    /**
     * 数据处理
     * @param array $list
     * @return array
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public static function buildMessageList(&$list)
    {
        $mids = array_unique(array_column($list, 'uid'));
        $memberList = Db::name("StoreMember")->whereIn('id', $mids)->select();
        foreach ($list as $key => $vo) {
            $list[$key]['nickname'] = '';
            foreach ($memberList as $member) {
                ($vo['uid'] === $member['id']) && $list[$key]['nickname'] = ToolsService::emojiDecode($member['nickname']);
            }
        }
        return $list;
    }

}